home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-18 | 2.8 KB | 64 lines | [TEXT/ToyS] |
- --this script should be compiled and saved as an application before running
- --
- -- Variables available for use:
- -- http_search_args - stuff in the URL after a ?
- -- path_args - stuff in the URL after a $
- -- post_args - stuff sent from forms, etc. when POST method is used
- -- method - GET, POST, etc. Used to tell if post_args are valid
- -- client_address - IP address or domain name of remote client's host
- -- from_user - non-standard. e-mail address of remote user
- -- username - authenticated user name
- -- password - authenticated password
- -- server_name - name or IP address of this server
- -- server_port - TCP/IP port number being used by this server
- -- script_name - URL name of this script
- -- referer - the URL of the page referencing this document
- -- user_agent - the name and version of the WWW client software being used
- -- content_type - MIME content type of post_args
-
- property crlf : (ASCII character 13) & (ASCII character 10)
-
- --this builds the normal HTTP header for regular access
- property http_10_header : "HTTP/1.0 200 OK" & crlf & "Server: MacHTTP" & crlf & ¬
- "MIME-Version: 1.0" & crlf & "Content-type: text/html" & crlf & crlf
-
- --this builds the redirect HTTP header for regular access
- property redirect_header : "HTTP/1.0 302 Found" & crlf & "Server: MacHTTP" & crlf & ¬
- "MIME-Version: 1.0" & crlf & "Location: http://"
-
- --stuff a simple HTML document in this property
- property body_text : "<title>Map Demo</title><h1>Map Demo</h1>" & ¬
- "<a href=map.cgi><img src=map.gif ismap></a><p>Click Me!<p>"
-
-
- try --wrap the whole script in an error handler
-
- -- http_search_args variable will contain the click coordinates.
- -- if they're blank, let's return a simple HTML document to prompt the user.
- if http_search_args = "" then
- return http_10_header & body_text
- else
- -- otherwise, extract the x and y coordinates from this variable
- set AppleScript's text item delimiters to ","
- set x to (text item 1 of http_search_args) as integer
- set y to (text item 2 of http_search_args) as integer
-
- -- Now figure out where we clicked
- if x < 36 and y < 36 then
- set answer_text to "You clicked ONE."
- return http_10_header & body_text & "You clicked ONE. x=" & x & " y=" & y
- else if x < 72 and y < 36 then
- return http_10_header & body_text & "You clicked TWO. x=" & x & " y=" & y
- else if y < 36 then
- return http_10_header & body_text & "You clicked THREE. x=" & x & " y=" & y
- else
- --build a redirect message, using this host's name, etc.
- -- and return the MacHTTP icon in the Images folder. Note the 2 trailing crlf's
- return redirect_header & server_name & ":" & server_port & "/Images/MacHTTP.gif" & crlf & crlf
- end if
- end if
-
- on error msg number num --report the error message and number to the WWW client
- return http_10_header & "Error " & num & ", " & msg
- end try
-